<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>res_edit.html</title>
</head>
<body>
	<script type="text/javascript">
		var winUnitAdd = new Windows("unit_add");
		var oUnitAdd = {
			initForm : function(){
 				winUnitAdd.find("#unitForm").form({
					url : '$!basePath/admin/unit/doAdd',
					onSubmit : function() {
						var pass = winUnitAdd.find('#unitForm').form("validate");
						if (pass) {
							winUnitAdd.find("#ok").linkbutton("loading");
						}
						return pass;
					},
					success : function(data) {
						var result = jQuery.parseJSON(data);
						if (result.success == true) {
							top.Notiy.success("添加成功!");
							winUnitAdd.setReturnValue(true);
							winUnitAdd.close();
						} else {
							top.Dialog.alert("提示", result.error, "error");
						}
						winUnitAdd.find("#ok").linkbutton("reset");
					}
				});
	 		},
	 		typeOnChange : function(n,o){
	 			winUnitAdd.find('#parentId').combotree({url: '$!basePath/admin/unit/unitTree?typeId='+n+''});  
	 		},
	 		ok : function(){
	 			winUnitAdd.find('#unitForm').submit();
	 		},
	 		cancel : function(){
				winUnitAdd.close();
	 		}
		};
		$(function() {
			 oUnitAdd.initForm();
		});
	</script>
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'center',border:false">
			<form id="unitForm" method="post" style="padding-top:10px;padding-left: 20px;">
				<table width="90%" >
					<tr>
						<td>部门类型：</td>
						<td><select id="type" name="unitType.id" class="easyui-combotree"
							style="width: 204px;"
							data-options="url:'$!basePath/admin/unit/getunitTypeTree',animate:true, required: true,
						onChange:oUnitAdd.typeOnChange">
						<option selected="selected">请选择</option></select></td>
					</tr>
					<tr>
						<td>上级部门：</td>
						<td><select id="parentId" name="parentId"
							class="easyui-combotree" data-options="required:true,onSelect:function(record){
								winUnitAdd.find('#unitForm').find('input[name=code]').val(record.code);
							}" style="width: 204px;"
							>
						<option selected="selected" value="0">无上级部门</option></select></td>
					</tr>
					<tr>
						<td>部门名称：</td>
						<td><input type="text" class="easyui-validatebox" name="name"
							maxlength="50" data-options="required:true" style="width: 90%;" />
						</td>
					</tr>
					<tr id="bianma">
						<td>部门编码：</td>
						<td><input type="text" class="easyui-validatebox" name="code"
							maxlength="50" data-options="required:true" style="width: 90%;" />
						</td>
					</tr>
					<tr>
						<td>EMail：</td>
						<td><input type="text" class="easyui-validatebox"
							name="EMail" maxlength="100" style="width: 90%;" data-options="validType:'email'" /></td>
					</tr>
					<tr>
						<td>地址：</td>
						<td><textarea class="easyui-textarea" rows="3" style="width: 90%;" cols="21" name="address"></textarea></td>
					</tr>

					<tr>
						<td>首页：</td>
						<td><textarea class="easyui-textarea" rows="3" style="width: 90%;" cols="21" name="web"></textarea></td>
					</tr>
				</table>
			</form>
		</div>
		<!--Change Button Text-->
		<div data-options="region:'south',border:false">
			<div class="dialog-button">
				<a id="ok" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="oUnitAdd.ok()">确定</a>
				<a id="cancel" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="oUnitAdd.cancel()">取消</a>
			</div>
		</div>
	</div>
</body>
</html>